package com.rush.rushaicodemother.core.parser;

import com.rush.rushaicodemother.exception.BusinessException;
import com.rush.rushaicodemother.exception.ErrorCode;
import com.rush.rushaicodemother.model.enums.CodeGenTypeEnum;

public class CodeParserExecutor {
    private static final HtmlCodeParser htmlCodeParser = new HtmlCodeParser();
    private static final MultiFileCodeParser multiFileCodeParser = new MultiFileCodeParser();
    /**
     * 统一入口：根据类型生成并保存代码
     * @param prompt
     * @param codeGenType
     * @return
     */
    public static Object executeParser(String prompt, CodeGenTypeEnum codeGenType)
    {
        if (codeGenType == null){
            throw new BusinessException(ErrorCode.SYSTEM_ERROR , "生成类型为空");
        }
        return switch (codeGenType){
            case HTML -> htmlCodeParser.parseCode(prompt);
            case MULTI_FILE -> multiFileCodeParser.parseCode(prompt);
            default -> throw new BusinessException(ErrorCode.SYSTEM_ERROR , "不支持的生成类型");
        };
    }
}
